using System;
using UnityEngine;
using System.Collections.Generic;
using ResourceSystem;

public class WindowInfo:ScriptableObject,IDataCollectionTemplete
{
    public List<WindowData>  Data = new List<WindowData>();
    /// <summary>
    /// 获得内容Type
    /// </summary>
    public Type GetContenType()
    {
        return typeof(WindowData);
    }
    /// <summary>
    /// 转换成当前内容类型的列表
    /// </summary>
    public void ConvertToContentList(List<IDataTemplete> contents)
    {
       for(int i = 0; i < contents.Count; i++)
       {
           Data.Add((WindowData)contents[i]);
       }
    }
}


[Serializable]
public class WindowData:IDataTemplete
{
    /// <summary>
    /// 索引号
    /// </summary>
    public int ID ;
    /// <summary>
    /// 名称
    /// </summary>
    public string Name ;
    /// <summary>
    /// 预制体名称
    /// </summary>
    public string PrefabName ;
    /// <summary>
    /// 层级
    /// </summary>
    public int Layer ;
    /// <summary>
    /// 是否常驻
    /// </summary>
    public bool Resident ;
    /// <summary>
    /// 是否只有一个
    /// </summary>
    public bool IsSingleton ;
    /// <summary>
    /// 是否为空
    /// </summary>
    public bool IsEmpty { get; set; }
    /// <summary>
    /// 构造方法
    /// </summary>
    public WindowData()
    {
        IsEmpty = true;
        ID= default(int);
        Name= default(string);
        PrefabName= default(string);
        Layer= default(int);
        Resident= default(bool);
        IsSingleton= default(bool);
    }
    /// <summary>
    /// 反序列化
    /// </summary>
    public void DeSerialize(object[] content)
    {
        ID = string.IsNullOrEmpty(content[0].ToString()) ? 0 : Int32.Parse(content[0].ToString());
        Name = content[1].ToString();
        PrefabName = content[2].ToString();
        Layer = string.IsNullOrEmpty(content[3].ToString()) ? 0 : Int32.Parse(content[3].ToString());
        Resident = content[4].ToString() == "0" ? false : true;
        IsSingleton = content[5].ToString() == "0" ? false : true;
        for(int i = 0 ;i < content.Length ; i++ )
        {
             if(content[i] != null)
             {
                 IsEmpty = false;
             }
        }
    }
}